window.onload = function() {
	$('#userContainer').hide()
	$("#tabLogo").click( function () {
		$('#newsContainer').show()
		$('#userContainer').hide()
	});	
	$("#tabUser").click( function (){
		$('#userContainer').show()
		$('#newsContainer').hide()
	});

	$("#guonei").click(function(){
		$('#newsContainer').hide()
		$('#userContainer').hide()
		$('#guojiNews').hide()	
		$('#guoneiNews').show()	
		$('#junshiNews').hide()	
		$('#kejiNews').hide()		
	});
	$("#guoji").click(function(){
		$('#newsContainer').hide()
		$('#userContainer').hide()
		$('#guojiNews').show()
		$('#guoneiNews').hide()	
		$('#junshiNews').hide()	
		$('#kejiNews').hide()	
	});

	$("#junshi").click(function(){
		$('#newsContainer').hide()
		$('#userContainer').hide()
		$('#guojiNews').hide()	
		$('#guoneiNews').hide()		
		$('#junshiNews').show()
		$('#kejiNews').hide()	
	});
	$("#keji").click(function(){
		$('#newsContainer').hide()
		$('#userContainer').hide()
		$('#guojiNews').hide()	
		$('#guoneiNews').hide()	
		$('#junshiNews').hide()	
		$('#kejiNews').show()
		// return window.naviType = "keji"; 
	});
	// naviType = "guoji";
	// console.dir(naviType);
	  
	$.ajax({
		type: "get",
		url: "http://localhost:8082/user/news?type=" + "guonei",
		data: "",
		dataType: "json",
		success: function (response) {
			let data = response.result.data
			let oNewOriHtml = $('#newsContainer').html();
			
			data.forEach(item => {
				oNewOriHtml += `
				<div class="news-item">
				<div class="img" id = "${item.uniquekey}">
                        <img class="img"
                                src="${item.thumbnail_pic_s}"
                                alt="">
                    </div>
                    <div class="info">
                        <div class="title">
						标题: ${item.title}
                        </div>
                        <div class="author">
						作者: ${item.author_name}
                        </div>
                        <div class="date author">
						日期: ${item.date}
                        </div> 
                    </div>
					</div>
				`
			});
			$('#newsContainer').html(oNewOriHtml);
			// 设置点击事件
			data.forEach(item => {
				$('#' + item.uniquekey).click(function(e){
					e.preventDefault();
					window.open(item.url)
				});
			});
			
			
		}
	});
	
	
	$.ajax({
		
		type: "get",
		url: "http://localhost:8082/user/news?type=" + "guonei",
		data: "",
		dataType: "json",
		success: function (response) {
			let data = response.result.data
			let oNewOriHtml = $('#guoneiNews').html();
			
			data.forEach(item => {
				oNewOriHtml += `
				<div class="news-item">
				<div class="img" id = "${item.uniquekey}">
	                    <img class="img"
	                            src="${item.thumbnail_pic_s}"
	                            alt="">
	                </div>
	                <div class="info">
	                    <div class="title">
						标题: ${item.title}
	                    </div>
	                    <div class="author">
						作者: ${item.author_name}
	                    </div>
	                    <div class="date author">
						日期: ${item.date}
	                    </div> 
	                </div>
					</div>
				`
			});
			$('#guoneiNews').html(oNewOriHtml);
			// 设置点击事件
			data.forEach(item => {
				$('#' + item.uniquekey).click(function(e){
					e.preventDefault();
					window.open(item.url)
				});
			});
			
			
		}
	});
	
	
	$.ajax({
		type: "get",
		url: "http://localhost:8082/user/news?type=" + "guoji",
		data: "",
		dataType: "json",
		success: function (response) {
			let data = response.result.data
			let oNewOriHtml = $('#guojiNews').html();
			
			data.forEach(item => {
				oNewOriHtml += `
				<div class="news-item">
				<div class="img" id = "${item.uniquekey}">
	                    <img class="img"
	                            src="${item.thumbnail_pic_s}"
	                            alt="">
	                </div>
	                <div class="info">
	                    <div class="title">
						标题: ${item.title}
	                    </div>
	                    <div class="author">
						作者: ${item.author_name}
	                    </div>
	                    <div class="date author">
						日期: ${item.date}
	                    </div> 
	                </div>
					</div>
				`
			});
			$('#guojiNews').html(oNewOriHtml);
			// 设置点击事件
			data.forEach(item => {
				$('#' + item.uniquekey).click(function(e){
					e.preventDefault();
					window.open(item.url)
				});
			});
			
			
		}
	});
	
	$.ajax({
		
		type: "get",
		url: "http://localhost:8082/user/news?type=" + "junshi",
		data: "",
		dataType: "json",
		success: function (response) {
			 let data = response.result.data
			let oNewOriHtml = $('#junshiNews').html();
			
			data.forEach(item => {
				oNewOriHtml += `
				<div class="news-item">
				<div class="img" id = "${item.uniquekey}">
	                    <img class="img"
	                            src="${item.thumbnail_pic_s}"
	                            alt="">
	                </div>
	                <div class="info">
	                    <div class="title">
						标题: ${item.title}
	                    </div>
	                    <div class="author">
						作者: ${item.author_name}
	                    </div>
	                    <div class="date author">
						日期: ${item.date}
	                    </div> 
	                </div>
					</div>
				`
			});
			$('#junshiNews').html(oNewOriHtml);
			// 设置点击事件
			data.forEach(item => {
				$('#' + item.uniquekey).click(function(e){
					e.preventDefault();
					window.open(item.url)
				});
			});
			
			
		}
	});

	$.ajax({
		
		type: "get",
		url: "http://localhost:8082/user/news?type=" + "keji",
		data: "",
		dataType: "json",
		success: function (response) {
			let data = response.result.data
			let oNewOriHtml = $('#kejiNews').html();
			
			data.forEach(item => {
				oNewOriHtml += `
				<div class="news-item">
				<div class="img" id = "${item.uniquekey}">
	                    <img class="img"
	                            src="${item.thumbnail_pic_s}"
	                            alt="">
	                </div>
	                <div class="info">
	                    <div class="title">
						标题: ${item.title}
	                    </div>
	                    <div class="author">
						作者: ${item.author_name}
	                    </div>
	                    <div class="date author">
						日期: ${item.date}
	                    </div> 
	                </div>
					</div>
				`
			});
			$('#kejiNews').html(oNewOriHtml);
			// 设置点击事件
			data.forEach(item => {
				$('#' + item.uniquekey).click(function(e){
					e.preventDefault();
					window.open(item.url)
				});
			});
			
			
		}
	});

}